{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-08-04T02:58:16.400143Z",
     "start_time": "2025-08-04T02:58:15.398691Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "\n",
    "s1 = pd.Series([1, 2, 3, 4, 5])\n",
    "print(s1)\n"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    1\n",
      "1    2\n",
      "2    3\n",
      "3    4\n",
      "4    5\n",
      "dtype: int64\n"
     ]
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-04T03:01:15.568204Z",
     "start_time": "2025-08-04T03:01:15.559274Z"
    }
   },
   "cell_type": "code",
   "source": [
    "s1 = pd.Series([1, 2, 3, 4, 5], index=['a', 'b', 'c', 'd', 'e'])\n",
    "print(s1)"
   ],
   "id": "6b8346db940e6443",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    1\n",
      "b    2\n",
      "c    3\n",
      "d    4\n",
      "e    5\n",
      "dtype: int64\n"
     ]
    }
   ],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-04T03:15:28.829407Z",
     "start_time": "2025-08-04T03:15:28.821948Z"
    }
   },
   "cell_type": "code",
   "source": "print(pd.Series([1, 2, 3, 4, 5], index=['a', 'b', 'c', 'd', 'e'], name='numbers'))",
   "id": "73c0cc5e806e3573",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    1\n",
      "b    2\n",
      "c    3\n",
      "d    4\n",
      "e    5\n",
      "Name: numbers, dtype: int64\n"
     ]
    }
   ],
   "execution_count": 6
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "d68e2d9a8c59a8da"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "b979a70476ea5455"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-04T03:17:07.180326Z",
     "start_time": "2025-08-04T03:17:07.168575Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 通过字典创建\n",
    "s2 = pd.Series({'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}, name='numbers')\n",
    "print(s2)"
   ],
   "id": "78bb9825785b6568",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    1\n",
      "b    2\n",
      "c    3\n",
      "d    4\n",
      "e    5\n",
      "Name: numbers, dtype: int64\n"
     ]
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:39:02.838464Z",
     "start_time": "2025-08-07T01:39:01.803762Z"
    }
   },
   "cell_type": "code",
   "source": "import pandas as pd",
   "id": "2535cd03898bb9c0",
   "outputs": [],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:39:11.375358Z",
     "start_time": "2025-08-07T01:39:11.368519Z"
    }
   },
   "cell_type": "code",
   "source": "s2 = pd.Series({'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}, name='numbers')",
   "id": "105fbe41b0a2d18",
   "outputs": [],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:39:16.471465Z",
     "start_time": "2025-08-07T01:39:16.463947Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.index)",
   "id": "78707bf6dd167313",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['a', 'b', 'c', 'd', 'e'], dtype='object')\n"
     ]
    }
   ],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:42:22.568616Z",
     "start_time": "2025-08-07T01:42:22.555987Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.values)",
   "id": "c24ab6f8f1063891",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3 4 5]\n"
     ]
    }
   ],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:42:51.153901Z",
     "start_time": "2025-08-07T01:42:51.148021Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.shape)",
   "id": "a6fa4cb6330ab30c",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5,)\n"
     ]
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:43:13.413166Z",
     "start_time": "2025-08-07T01:43:13.403711Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.ndim)",
   "id": "5233a8b8c90101e6",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "execution_count": 6
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:43:29.451568Z",
     "start_time": "2025-08-07T01:43:29.444545Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.size)",
   "id": "513baae19bfb6a10",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n"
     ]
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:44:02.786573Z",
     "start_time": "2025-08-07T01:44:02.778193Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.dtype)",
   "id": "72255c9f7da0cb9c",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "int64\n"
     ]
    }
   ],
   "execution_count": 9
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:44:32.821333Z",
     "start_time": "2025-08-07T01:44:32.815191Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.dtypes)",
   "id": "a1529d5917aee12e",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "int64\n"
     ]
    }
   ],
   "execution_count": 10
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:44:44.291064Z",
     "start_time": "2025-08-07T01:44:44.283457Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.name)",
   "id": "d5b62d3b9365c9f9",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "numbers\n"
     ]
    }
   ],
   "execution_count": 11
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:45:59.068278Z",
     "start_time": "2025-08-07T01:45:59.062816Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.loc['b'])",
   "id": "e937b3c3ca3149fc",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "execution_count": 12
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:46:23.128075Z",
     "start_time": "2025-08-07T01:46:20.254672Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.loc[0])",
   "id": "549a995e57cbe8b8",
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "0",
     "output_type": "error",
     "traceback": [
      "\u001B[31m---------------------------------------------------------------------------\u001B[39m",
      "\u001B[31mKeyError\u001B[39m                                  Traceback (most recent call last)",
      "\u001B[36mFile \u001B[39m\u001B[32m~\\miniconda3\\Lib\\site-packages\\pandas\\core\\indexes\\base.py:3812\u001B[39m, in \u001B[36mIndex.get_loc\u001B[39m\u001B[34m(self, key)\u001B[39m\n\u001B[32m   3811\u001B[39m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[32m-> \u001B[39m\u001B[32m3812\u001B[39m     \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m._engine.get_loc(casted_key)\n\u001B[32m   3813\u001B[39m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mKeyError\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m err:\n",
      "\u001B[36mFile \u001B[39m\u001B[32mindex.pyx:167\u001B[39m, in \u001B[36mpandas._libs.index.IndexEngine.get_loc\u001B[39m\u001B[34m()\u001B[39m\n",
      "\u001B[36mFile \u001B[39m\u001B[32mindex.pyx:196\u001B[39m, in \u001B[36mpandas._libs.index.IndexEngine.get_loc\u001B[39m\u001B[34m()\u001B[39m\n",
      "\u001B[36mFile \u001B[39m\u001B[32mpandas\\\\_libs\\\\hashtable_class_helper.pxi:7088\u001B[39m, in \u001B[36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001B[39m\u001B[34m()\u001B[39m\n",
      "\u001B[36mFile \u001B[39m\u001B[32mpandas\\\\_libs\\\\hashtable_class_helper.pxi:7096\u001B[39m, in \u001B[36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001B[39m\u001B[34m()\u001B[39m\n",
      "\u001B[31mKeyError\u001B[39m: 0",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001B[31mKeyError\u001B[39m                                  Traceback (most recent call last)",
      "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[13]\u001B[39m\u001B[32m, line 1\u001B[39m\n\u001B[32m----> \u001B[39m\u001B[32m1\u001B[39m \u001B[38;5;28mprint\u001B[39m(s2.loc[\u001B[32m0\u001B[39m])\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~\\miniconda3\\Lib\\site-packages\\pandas\\core\\indexing.py:1191\u001B[39m, in \u001B[36m_LocationIndexer.__getitem__\u001B[39m\u001B[34m(self, key)\u001B[39m\n\u001B[32m   1189\u001B[39m maybe_callable = com.apply_if_callable(key, \u001B[38;5;28mself\u001B[39m.obj)\n\u001B[32m   1190\u001B[39m maybe_callable = \u001B[38;5;28mself\u001B[39m._check_deprecated_callable_usage(key, maybe_callable)\n\u001B[32m-> \u001B[39m\u001B[32m1191\u001B[39m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m._getitem_axis(maybe_callable, axis=axis)\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~\\miniconda3\\Lib\\site-packages\\pandas\\core\\indexing.py:1431\u001B[39m, in \u001B[36m_LocIndexer._getitem_axis\u001B[39m\u001B[34m(self, key, axis)\u001B[39m\n\u001B[32m   1429\u001B[39m \u001B[38;5;66;03m# fall thru to straight lookup\u001B[39;00m\n\u001B[32m   1430\u001B[39m \u001B[38;5;28mself\u001B[39m._validate_key(key, axis)\n\u001B[32m-> \u001B[39m\u001B[32m1431\u001B[39m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m._get_label(key, axis=axis)\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~\\miniconda3\\Lib\\site-packages\\pandas\\core\\indexing.py:1381\u001B[39m, in \u001B[36m_LocIndexer._get_label\u001B[39m\u001B[34m(self, label, axis)\u001B[39m\n\u001B[32m   1379\u001B[39m \u001B[38;5;28;01mdef\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34m_get_label\u001B[39m(\u001B[38;5;28mself\u001B[39m, label, axis: AxisInt):\n\u001B[32m   1380\u001B[39m     \u001B[38;5;66;03m# GH#5567 this will fail if the label is not present in the axis.\u001B[39;00m\n\u001B[32m-> \u001B[39m\u001B[32m1381\u001B[39m     \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m.obj.xs(label, axis=axis)\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~\\miniconda3\\Lib\\site-packages\\pandas\\core\\generic.py:4320\u001B[39m, in \u001B[36mNDFrame.xs\u001B[39m\u001B[34m(self, key, axis, level, drop_level)\u001B[39m\n\u001B[32m   4318\u001B[39m             new_index = index[loc]\n\u001B[32m   4319\u001B[39m \u001B[38;5;28;01melse\u001B[39;00m:\n\u001B[32m-> \u001B[39m\u001B[32m4320\u001B[39m     loc = index.get_loc(key)\n\u001B[32m   4322\u001B[39m     \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(loc, np.ndarray):\n\u001B[32m   4323\u001B[39m         \u001B[38;5;28;01mif\u001B[39;00m loc.dtype == np.bool_:\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~\\miniconda3\\Lib\\site-packages\\pandas\\core\\indexes\\base.py:3819\u001B[39m, in \u001B[36mIndex.get_loc\u001B[39m\u001B[34m(self, key)\u001B[39m\n\u001B[32m   3814\u001B[39m     \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(casted_key, \u001B[38;5;28mslice\u001B[39m) \u001B[38;5;129;01mor\u001B[39;00m (\n\u001B[32m   3815\u001B[39m         \u001B[38;5;28misinstance\u001B[39m(casted_key, abc.Iterable)\n\u001B[32m   3816\u001B[39m         \u001B[38;5;129;01mand\u001B[39;00m \u001B[38;5;28many\u001B[39m(\u001B[38;5;28misinstance\u001B[39m(x, \u001B[38;5;28mslice\u001B[39m) \u001B[38;5;28;01mfor\u001B[39;00m x \u001B[38;5;129;01min\u001B[39;00m casted_key)\n\u001B[32m   3817\u001B[39m     ):\n\u001B[32m   3818\u001B[39m         \u001B[38;5;28;01mraise\u001B[39;00m InvalidIndexError(key)\n\u001B[32m-> \u001B[39m\u001B[32m3819\u001B[39m     \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mKeyError\u001B[39;00m(key) \u001B[38;5;28;01mfrom\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01merr\u001B[39;00m\n\u001B[32m   3820\u001B[39m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mTypeError\u001B[39;00m:\n\u001B[32m   3821\u001B[39m     \u001B[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001B[39;00m\n\u001B[32m   3822\u001B[39m     \u001B[38;5;66;03m#  InvalidIndexError. Otherwise we fall through and re-raise\u001B[39;00m\n\u001B[32m   3823\u001B[39m     \u001B[38;5;66;03m#  the TypeError.\u001B[39;00m\n\u001B[32m   3824\u001B[39m     \u001B[38;5;28mself\u001B[39m._check_indexing_error(key)\n",
      "\u001B[31mKeyError\u001B[39m: 0"
     ]
    }
   ],
   "execution_count": 13
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "1add29b98d00851c"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:46:41.307524Z",
     "start_time": "2025-08-07T01:46:41.301252Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.iloc[2])",
   "id": "15727bbd6d2b3a20",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "execution_count": 16
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:51:54.598258Z",
     "start_time": "2025-08-07T01:51:54.586003Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2.loc['c':'e'])",
   "id": "2c0b3b00dc05ed44",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "c    3\n",
      "d    4\n",
      "e    5\n",
      "Name: numbers, dtype: int64\n"
     ]
    }
   ],
   "execution_count": 17
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:54:56.558185Z",
     "start_time": "2025-08-07T01:54:56.551508Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2[1])",
   "id": "cbd2721aa218aa78",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\ALM\\AppData\\Local\\Temp\\ipykernel_19004\\427805744.py:1: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
      "  print(s2[1])\n"
     ]
    }
   ],
   "execution_count": 18
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "1f59ba37f4466d7"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T01:59:59.262964Z",
     "start_time": "2025-08-07T01:59:59.253233Z"
    }
   },
   "cell_type": "code",
   "source": "print(s2[s2 < 3])",
   "id": "2dacb263b4b167c7",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    1\n",
      "b    2\n",
      "Name: numbers, dtype: int64\n"
     ]
    }
   ],
   "execution_count": 20
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T02:20:54.676133Z",
     "start_time": "2025-08-07T02:20:54.669134Z"
    }
   },
   "cell_type": "code",
   "source": [
    "s3 = pd.Series({'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6}, name='numbers')\n",
    "print(s3.head())"
   ],
   "id": "7a8fdef346107027",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    1\n",
      "b    2\n",
      "c    3\n",
      "d    4\n",
      "e    5\n",
      "Name: numbers, dtype: int64\n"
     ]
    }
   ],
   "execution_count": 21
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T02:23:54.083781Z",
     "start_time": "2025-08-07T02:23:54.078325Z"
    }
   },
   "cell_type": "code",
   "source": "print(s3.tail())",
   "id": "98b747d003eaefb2",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "b    2\n",
      "c    3\n",
      "d    4\n",
      "e    5\n",
      "f    6\n",
      "Name: numbers, dtype: int64\n"
     ]
    }
   ],
   "execution_count": 22
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T02:40:32.665872Z",
     "start_time": "2025-08-07T02:40:32.658995Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import numpy as np\n",
    "\n",
    "s = pd.Series([1, 2, 3, np.nan, None, 4, 5], index=['a', 'b', 'c', 'd', 'e', 'f', 'g'],name=\"测试数据\")\n",
    "print(s.head())"
   ],
   "id": "cc918e0403f2459b",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    1.0\n",
      "b    2.0\n",
      "c    3.0\n",
      "d    NaN\n",
      "e    NaN\n",
      "Name: 测试数据, dtype: float64\n"
     ]
    }
   ],
   "execution_count": 25
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "727c839368330416"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T02:43:00.835255Z",
     "start_time": "2025-08-07T02:43:00.820470Z"
    }
   },
   "cell_type": "code",
   "source": "s.describe()",
   "id": "c9a2df424672e920",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count    5.000000\n",
       "mean     3.000000\n",
       "std      1.581139\n",
       "min      1.000000\n",
       "25%      2.000000\n",
       "50%      3.000000\n",
       "75%      4.000000\n",
       "max      5.000000\n",
       "Name: 测试数据, dtype: float64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 27
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T02:45:57.272062Z",
     "start_time": "2025-08-07T02:45:57.266029Z"
    }
   },
   "cell_type": "code",
   "source": [
    "print(s.keys())\n",
    "print(s.index)"
   ],
   "id": "b4d3cb899528b466",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['a', 'b', 'c', 'd', 'e', 'f', 'g'], dtype='object')\n",
      "Index(['a', 'b', 'c', 'd', 'e', 'f', 'g'], dtype='object')\n"
     ]
    }
   ],
   "execution_count": 28
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T02:47:24.453209Z",
     "start_time": "2025-08-07T02:47:24.448104Z"
    }
   },
   "cell_type": "code",
   "source": "print(s.isna())",
   "id": "b2cc7dc401ac4253",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    False\n",
      "b    False\n",
      "c    False\n",
      "d     True\n",
      "e     True\n",
      "f    False\n",
      "g    False\n",
      "Name: 测试数据, dtype: bool\n"
     ]
    }
   ],
   "execution_count": 29
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T02:49:21.349651Z",
     "start_time": "2025-08-07T02:49:20.253966Z"
    }
   },
   "cell_type": "code",
   "source": "s.isin(4)",
   "id": "efd0913d99e9d317",
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "only list-like objects are allowed to be passed to isin(), you passed a `int`",
     "output_type": "error",
     "traceback": [
      "\u001B[31m---------------------------------------------------------------------------\u001B[39m",
      "\u001B[31mTypeError\u001B[39m                                 Traceback (most recent call last)",
      "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[30]\u001B[39m\u001B[32m, line 1\u001B[39m\n\u001B[32m----> \u001B[39m\u001B[32m1\u001B[39m s.isin(\u001B[32m4\u001B[39m)\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~\\miniconda3\\Lib\\site-packages\\pandas\\core\\series.py:5570\u001B[39m, in \u001B[36mSeries.isin\u001B[39m\u001B[34m(self, values)\u001B[39m\n\u001B[32m   5497\u001B[39m \u001B[38;5;28;01mdef\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34misin\u001B[39m(\u001B[38;5;28mself\u001B[39m, values) -> Series:\n\u001B[32m   5498\u001B[39m \u001B[38;5;250m    \u001B[39m\u001B[33;03m\"\"\"\u001B[39;00m\n\u001B[32m   5499\u001B[39m \u001B[33;03m    Whether elements in Series are contained in `values`.\u001B[39;00m\n\u001B[32m   5500\u001B[39m \n\u001B[32m   (...)\u001B[39m\u001B[32m   5568\u001B[39m \u001B[33;03m    dtype: bool\u001B[39;00m\n\u001B[32m   5569\u001B[39m \u001B[33;03m    \"\"\"\u001B[39;00m\n\u001B[32m-> \u001B[39m\u001B[32m5570\u001B[39m     result = algorithms.isin(\u001B[38;5;28mself\u001B[39m._values, values)\n\u001B[32m   5571\u001B[39m     \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m._constructor(result, index=\u001B[38;5;28mself\u001B[39m.index, copy=\u001B[38;5;28;01mFalse\u001B[39;00m).__finalize__(\n\u001B[32m   5572\u001B[39m         \u001B[38;5;28mself\u001B[39m, method=\u001B[33m\"\u001B[39m\u001B[33misin\u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m   5573\u001B[39m     )\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~\\miniconda3\\Lib\\site-packages\\pandas\\core\\algorithms.py:477\u001B[39m, in \u001B[36misin\u001B[39m\u001B[34m(comps, values)\u001B[39m\n\u001B[32m    472\u001B[39m     \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mTypeError\u001B[39;00m(\n\u001B[32m    473\u001B[39m         \u001B[33m\"\u001B[39m\u001B[33monly list-like objects are allowed to be passed \u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m    474\u001B[39m         \u001B[33mf\u001B[39m\u001B[33m\"\u001B[39m\u001B[33mto isin(), you passed a `\u001B[39m\u001B[38;5;132;01m{\u001B[39;00m\u001B[38;5;28mtype\u001B[39m(comps).\u001B[34m__name__\u001B[39m\u001B[38;5;132;01m}\u001B[39;00m\u001B[33m`\u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m    475\u001B[39m     )\n\u001B[32m    476\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m is_list_like(values):\n\u001B[32m--> \u001B[39m\u001B[32m477\u001B[39m     \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mTypeError\u001B[39;00m(\n\u001B[32m    478\u001B[39m         \u001B[33m\"\u001B[39m\u001B[33monly list-like objects are allowed to be passed \u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m    479\u001B[39m         \u001B[33mf\u001B[39m\u001B[33m\"\u001B[39m\u001B[33mto isin(), you passed a `\u001B[39m\u001B[38;5;132;01m{\u001B[39;00m\u001B[38;5;28mtype\u001B[39m(values).\u001B[34m__name__\u001B[39m\u001B[38;5;132;01m}\u001B[39;00m\u001B[33m`\u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m    480\u001B[39m     )\n\u001B[32m    482\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(values, (ABCIndex, ABCSeries, ABCExtensionArray, np.ndarray)):\n\u001B[32m    483\u001B[39m     orig_values = \u001B[38;5;28mlist\u001B[39m(values)\n",
      "\u001B[31mTypeError\u001B[39m: only list-like objects are allowed to be passed to isin(), you passed a `int`"
     ]
    }
   ],
   "execution_count": 30
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T02:49:52.407766Z",
     "start_time": "2025-08-07T02:49:52.401294Z"
    }
   },
   "cell_type": "code",
   "source": "print(s.isin([4,5]))",
   "id": "d40239b7ed921d91",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    False\n",
      "b    False\n",
      "c    False\n",
      "d    False\n",
      "e    False\n",
      "f     True\n",
      "g     True\n",
      "Name: 测试数据, dtype: bool\n"
     ]
    }
   ],
   "execution_count": 33
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T03:00:56.441515Z",
     "start_time": "2025-08-07T03:00:56.431381Z"
    }
   },
   "cell_type": "code",
   "source": [
    "np.random.seed(42)\n",
    "scores = pd.Series(np.random.randint(50,101,10), index=['学生'+str(i) for i in range(1,11)])"
   ],
   "id": "11efe6a3fee249a1",
   "outputs": [],
   "execution_count": 34
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T03:01:01.225870Z",
     "start_time": "2025-08-07T03:01:01.219918Z"
    }
   },
   "cell_type": "code",
   "source": "print(scores)",
   "id": "5828551b7924de3b",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "学生1     88\n",
      "学生2     78\n",
      "学生3     64\n",
      "学生4     92\n",
      "学生5     57\n",
      "学生6     70\n",
      "学生7     88\n",
      "学生8     68\n",
      "学生9     72\n",
      "学生10    60\n",
      "dtype: int32\n"
     ]
    }
   ],
   "execution_count": 35
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T03:01:20.874098Z",
     "start_time": "2025-08-07T03:01:20.867738Z"
    }
   },
   "cell_type": "code",
   "source": "print(scores.max())",
   "id": "18fc6465badb9537",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "92\n"
     ]
    }
   ],
   "execution_count": 36
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "57eed274eb27c07b"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T03:05:46.527411Z",
     "start_time": "2025-08-07T03:05:46.520726Z"
    }
   },
   "cell_type": "code",
   "source": "print(scores.min())",
   "id": "70e7c47e8d157f2c",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "57\n"
     ]
    }
   ],
   "execution_count": 37
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T03:05:58.012717Z",
     "start_time": "2025-08-07T03:05:58.007198Z"
    }
   },
   "cell_type": "code",
   "source": "print(scores.mean())",
   "id": "8bb837ce32b34a29",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "73.7\n"
     ]
    }
   ],
   "execution_count": 38
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-07T03:06:16.349131Z",
     "start_time": "2025-08-07T03:06:16.343162Z"
    }
   },
   "cell_type": "code",
   "source": [
    "print(scores.count(\n",
    "))"
   ],
   "id": "1d5e239abc25fb9d",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "execution_count": 39
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "83a2ab98fe75c54c"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
